<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // var a = {};//创建了一个空的对象

        // var student = {
        //     name: "蔡徐坤",
        //     height: 175,
        //     weight: 170,
        //     sayHello: function() {
        //         console.log("hello");
        //     }
        // };

        // //1、使用 . 成员访问运算符来访问属性
        // console.log(student.name);
        // //2、使用 [ ] 访问属性，此时属性需要加上引号
        // console.log(student['height']);
        // //3、调用方法，记得要加上 ()
        // student.sayHello();


        // var student = new Object();//和创建数组类似
        // student.name = "蔡徐坤";
        // student.height = 175;
        // student["weight"] = 170;
        // student.sayHello = function() {
        //     console.log("hello");
        // }
        
        // console.log(student.name);
        // console.log(student["weight"]);
        // student.sayHello();

        function Cat(name, type, sound) {
            this.name = name;
            this.type = type;
            this.miao = function() {
                console.log(sound);// 别忘了作⽤域的链式访问规则
            }
        }

        var mimi = new Cat("咪咪", "中华田园猫", "喵");
        var xiaohei = new Cat("小黑", "波斯猫", "猫呜呜呜");
        var ciqiu = new Cat("刺球", "布鲁斯猫", "咕噜噜");

        console.log(mimi);
        mimi.miao;

    </script>
</body>
</html>